package com.ftg.learn.chapter10.work02;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Supplier;

/**
 * 售货员
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/2/1 上午10:51
 */
public class Saler<E extends Product> {

    public E info(int sno,String name,double price,CreateProduct<E> cp){
        E p1 = cp.create();
        p1.setName(name);
        p1.setSno(sno);
        p1.setPrice(price);
        return p1;
    }

//    public E info(int sno,String name,double price,Supplier<E> cp){
//        E p1 = cp.get();
//        p1.setName(name);
//        p1.setSno(sno);
//        p1.setPrice(price);
//        return p1;
//    }

    public static void main(String[] args) {
        Saler<Pet> s = new Saler<>();
        Product p1 = s.info(1,"泰迪",240,Pet::new);
        Product p2 = s.info(2,"哈士奇",120,Pet::new);


        //方法引用
        Saler<Meat> s1 = new Saler<>();
        s1.info(3,"beef",48.4,Meat::new);
    }

}
